/* -----------------------------------------------------------------------------
 * PROJECT    : lwf_common
 * FILE       : VerticalSliderInfo.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Oct 11, 2011  mycodetalks			       Created
 */
package net.lwf.common;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.StringTokenizer;

import net.lwf.common.constant.ICommonConstant;

public class VerticalSliderInfo {
	
	private static VerticalSliderInfo instance; 
	private String dataresource = "verticalslider_data";
	private Map<String, String[]> mapInfo;
	
	private VerticalSliderInfo() {
		this.init();
	}
	
	public synchronized static final VerticalSliderInfo getInstance() {
		if(instance == null) {
			instance = new VerticalSliderInfo();
		}
		return instance;
	}
	
	
	public Map<String, String[]> getMapInfo() {
		return mapInfo;
	}

	private void init() {
		ResourceBundle bundle = PropertyResourceBundle.getBundle(dataresource);
		if(mapInfo == null) {
			mapInfo = new HashMap<String, String[]>();
		}
		Enumeration<String> data = bundle.getKeys();
		while(data.hasMoreElements()) {
			String key = data.nextElement().toString();
			StringTokenizer stk = new StringTokenizer(bundle.getString(key), ICommonConstant.COMMA);
			String[] dataarray = new String[stk.countTokens()];
			int counter = 0;
			while(stk.hasMoreTokens()) {
				dataarray[counter] = stk.nextToken();
				counter++;
			}
			mapInfo.put(key, dataarray);
		}
	}

}
